#include "stdafx.h"

namespace cpputils
{

int safe_main(int (*mymain)(int, char**), int argc, char** argv)
{
	try
	{
		return mymain(argc, argv);
	}
	catch (exception& E)
	{
		printf("Exception is thrown!\n");
		printf("Type: %s\n", typeid(E).name());
		printf("What: %s\n", E.what());
	}
	catch (...)
	{
		printf("Unknown exception is thrown!\n");
	}
	return 1;
}

}
